<?php
include "../../../lib/list.php";
if ($sg_no = $_GET['sg_no']){
	$sear_char .= " and sg_no = $sg_no";
}
if($sg_no != '-1'){
	$sear_char .= " and sg_no != '-1'";;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<link rel="stylesheet" href="../../../css/list.css" type="text/css"/>
<link rel="stylesheet" href="../../../css/table.blue.sorter.css" type="text/css" media="print, projection, screen" />
<link rel="stylesheet" href="../../../css/jquery.tablesorter.pager.css" type="text/css" media="print, projection, screen" />
<script type="text/javascript" src="../../../js/jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../../js/jquery.tablesorter.pager.js"></script>
<script type="text/javascript" src="../../../js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="../../../js/list.js"></script>
<script type="text/javascript">
	$(function(){
		$("table")
			.tablesorter({headers: {             
     		    0: {               
        		     // 정렬선택 안함
        		     sorter: false         
        		    }         
        		   },widthFixed: true, widgets: ['zebra'] })
			.tablesorterPager({container: $("#pager")});
	});
	</script>
</head>
<body>
	<div style="width:1024px;padding:10px;">
	<div style="border-bottom:1px solid #e8e8e8; text-align:left; font-size:12px; margin-bottom:12px; color:#9a9a9a">::: 마스터 관리&nbsp;⇒&nbsp;점포마스터</div>
	<div style="float:left;"><?echo shopgroup($sg_no)?></div>
	<div style="float:right;padding:5px;">
	<input type="button" class="button red small" value="폐점하기 " onclick="javascript:list_close();" />
	<input type="button" class="button green small"	value="수정하기" onclick="javascript:list_modify();" /> 
	<input type="button" class="button white small"	value="입력하기"  onclick="javascript:location.href='insert.php'"/>
	</div>
	<form name="view" method="post"	action="insert.php">
	<input type="hidden" value="" name="mode" />
		<table cellspacing="1" class="tablesorter">
			<thead>
				<tr>
						<th width="10px"><input
									onclick="if (this.checked) all_checked(true); else all_checked(false);"
									type=checkbox tabindex=1 />
								</th>
								<th width="30px">no</th>
								<th>그룹</th>
								<th>점포 명</th>
								<th>담당자 수</th>
								<th>생성일</th>
								<th>책임자</th>
				</tr>
			</thead>
			<tfoot>
				<tr>
					<th width="10px">&nbsp;
								</th>	
								<th width="30px">no</th>
								<th>그룹</th>
								<th>점포 명</th>
								<th>담당자 수</th>
								<th>생성일</th>
								<th>책임자</th>
				</tr>
			</tfoot>
			<tbody>
						<?php
						
						$query = "select * from uatp_shopinfo where 1 $sear_char order by no DESC ";
						$total = DBnumrows($query);
						$result = DBquery($query);
						for($i=1; $list = mysql_fetch_array($result); $i++){
							$bunho = $total - $i + 1;
							$qry = "select * from uatp_shopgroup where no = ".$list['sg_no'];
							$sg_no = DBarray($qry);
							$sg_name = $sg_no['name'];
							$date_v = date('Y-m-d',strtotime($list['start']));
							$qry2  = "select * from uatp_staff where lv = 3 and s_no = ".$list['no'];
							$manager = DBarray($qry2);

							?>
							<tr onclick="javascript:chk(<?=$list['no']?>)">
								<td><input type=checkbox name=chk_no[]
									value="<?=$list['no']?>" onclick="javascript:chk(<?=$list['no']?>)"></input></td>
								<td align=center><?=$bunho?></td>
								<td><?=$sg_name?></td>
								<td <?=$MouseOver?> onclick="javascript:movepage('detail.php','s_no','<?=$list['no']?>');"><b><?=$list['name']?></b></td>
								<td <?=$MouseOver?> onclick="javascript:movepage('../staff/view.php','s_no','<?=$list['no']?>');"><?
							$sql = "select * from uatp_staff where s_no = ".$list['no']." order by no DESC";
							echo DBnumrows($sql);
							?></td>
								<td><?=$date_v?></td>
								<?if(!$manager){
							echo "<td $MouseOver onclick=javascript:movepage('../staff/view.php','s_no','$list[no]');><font color='#B4045F'>책임자를 선택해주세요.</font></td>";
							}
							else{ echo "<td $MouseOver onclick=javascript:movepage('../staff/detail.php','no','$manager[no]');><font color='black'>$manager[name]</font></td>";
							}?>
							</tr>							
<?php 
}
	mysql_free_result($result);
							
?>
			</tbody>
		</table>
		</form>
		
		<div id="pager" class="pager">
			<form>
				<img src="../../../image/first.png" class="first" /> <img
					src="../../../image/prev.png" class="prev" /> <input
					type="text" class="pagedisplay" /> <img
					src="../../../image/next.png" class="next" /> <img
					src="../../../image/last.png" class="last" /> <select
					class="pagesize">
					<option selected="selected" value="10">10</option>
					<option value="20">20</option>
					<option value="30">30</option>
					<option value="40">40</option>
				</select>
			</form>
				</div>
					
	</div>
</body>
</html>